package cc.sunni.api.controller.article;

import cc.sunni.common.utils.R;
import cc.sunni.pojo.bo.NewArticleBO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;

@Api(value = "文章业务的controller", tags = {"文章业务的controller"})
@RequestMapping("/article")
public interface ArticleControllerApi {

    @PostMapping("/createArticle")
    @ApiOperation(value = "用户发文", notes = "用户发文", httpMethod = "POST")
    R createArticle(@RequestBody @Validated NewArticleBO newArticleBO);

    @PostMapping("queryMyList")
    @ApiOperation(value = "查询用户的所有文章列表", notes = "查询用户的所有文章列表", httpMethod = "POST")
    R queryMyList(@RequestParam String userId, @RequestParam String keyword, @RequestParam Integer status, @RequestParam Date startDate, @RequestParam Date endDate,
                  @RequestParam(value = "page", required = false, defaultValue = "1") Integer page, @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize);

    @PostMapping("queryAllList")
    @ApiOperation(value = "管理员查询用户的所有文章列表", notes = "管理员查询用户的所有文章列表", httpMethod = "POST")
    R queryAllList(@RequestParam Integer status,
                   @ApiParam(name = "page", value = "查询下一页的第几页")
                   @RequestParam Integer page,
                   @ApiParam(name = "pageSize", value = "分页的每一页显示的条数")
                   @RequestParam Integer pageSize);


    @PostMapping("doReview")
    @ApiOperation(value = "管理员对文章进行审核通过或者失败", notes = "管理员对文章进行审核通过或者失败", httpMethod = "POST")
    R doReview(@RequestParam String articleId, @RequestParam Integer passOrNot);

    @PostMapping("/delete")
    @ApiOperation(value = "用户删除文章", notes = "用户删除文章", httpMethod = "POST")
    R delete(@RequestParam String userId, @RequestParam String articleId);

    @PostMapping("/withdraw")
    @ApiOperation(value = "用户撤回文章", notes = "用户撤回文章", httpMethod = "POST")
    R withdraw(@RequestParam String userId,  @RequestParam String articleId);
}
